﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ModuleItem.aspx.cs" Inherits="Manage_Cms_ModuleItem" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--#include file="../js/html_head.inc"-->
    <link rel="stylesheet" type="text/css" href="../Themes/<%=ManageHelper.GetTheme()%>/style.css" />
    <style type="text/css">
        table
        {
            width: 100%; 
            border-collapse: collapse; 
            border: solid; 
            border-color: #86B9D6 #D8DDE5 #D8DDE5; 
            border-width: 2px 1px 1px; 
        }
        table th,td
        {
            border:solid 1px #d8dde5;
            padding: 5px;
        }
        table th
        {
            background-color: #f3f7ff;
            background-image: none;
            background-repeat: repeat;
            background-attachment: scroll;
            background-position: 0% 0%;
            width: 210px;
            text-align: left;
            color: #0d58a5;
            font-weight: normal;
            text-align:right;
        }
        table td
        {
            text-align:left;
        }
        .red
        {
            color:Red;
        }
    </style>

    <script type="text/javascript">
    
    $(document).ready(function(){    
        $("#setp_2").hide();
    });


    function copyToClipboard(txt) {   
     if(window.clipboardData) {   
       window.clipboardData.clearData();   
       window.clipboardData.setData("Text", txt);   
       alert("模块参数已经复制到剪切板！");   
     } else if(navigator.userAgent.indexOf("Opera") != -1) {   
      window.location = txt;   
     } else if (window.netscape) {   
      try {   
       netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");   
      } catch (e) {   
       alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");   
      }   
      var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);   
      if (!clip)   
       return;   
      var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);   
      if (!trans)   
       return;   
      trans.addDataFlavor('text/unicode');   
      var str = new Object();   
      var len = new Object();   
      var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);   
      var copytext = txt;   
      str.data = copytext;   
      trans.setTransferData("text/unicode",str,copytext.length*2);   
      var clipid = Components.interfaces.nsIClipboard;   
      if (!clip)   
       return false;   
      clip.setData(trans,null,clipid.kGlobalClipboard);   
      alert("模块参数已经复制到剪切板！");   
     }   
    }
    
    function GetCode(act,id)
    {
        if($("#txtname").val()=='')
        {
            alert("请填写模块名称！");
            return false;
        }
        if($("#txttop").val()!='*')
        {
            var patrn=/^\d+$/; 
            if (!patrn.exec($("#txttop").val()))
            {
                alert("数据记录数应该输入数字！");
                return false;
            }
            else
            {
                GenerTagCode(act,id,($("#txtname").val()),$("#datatablelist").val(),$("#txttop").val(),encodeURIComponent($("#txtwhere").val()),$("#fieldsoption").val(),$("#direction").val())
                return true;
            }
            
        }
        if($("#txttop").val()=='*')
        {
            GenerTagCode(act,id,($("#txtname").val()),$("#datatablelist").val(),$("#txttop").val(),encodeURIComponent($("#txtwhere").val()),$("#fieldsoption").val(),$("#direction").val())
            return true;
        }
    }
    </script>

</head>
<body>
    <form>
        <div id="setp_1">
            <table>
                <tr>
                    <th class="th">
                        <strong style="color: #6774A8">模块名称</strong>
                    </th>
                    <td>
                        <input type="text" id="txtname" name="txtname" value="<%=modelTagModule.ModuleName %>"
                            style="width: 300px;" /><span class="red">&nbsp;由英文和数字组成，不能使用除“_”外的特殊符号</span>
                    </td>
                </tr>
                <tr>
                    <th class="th">
                        <strong style="color: #6774A8">模块数据源</strong>
                    </th>
                    <td>
                        <select name="datatablelist" id="datatablelist" onchange='GetFields($("#datatablelist").val())'
                            style="width: 305px;">
                            <%=BuildDataTableList(modelTagModule.DataTable) %>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th class="th">
                        <strong style="color: #6774A8">数据记录数(TOP)</strong>
                    </th>
                    <td>
                        <input type="text" style="width: 300px;" id="txttop" value="<%=modelTagModule.TopNum %>" /><span
                            class="red">&nbsp;默认查询100条数据，填写0为查询所有，页面可使用[ptl:if]标签控制输出</span>
                    </td>
                </tr>
                <tr>
                    <th class="th">
                        <strong style="color: #6774A8">自定义查询条件(WHERE)</strong>
                    </th>
                    <td>
                        <input type="text" style="width: 300px;" id="txtwhere" value="<%=modelTagModule.StrWhere %>" /><span
                            class="red">&nbsp;查询语句的WHERE的条件，可以为空，如：ContentID=1099 AND ORDERITEM='ID'</span>
                    </td>
                </tr>
                <tr>
                    <th class="th">
                        <strong style="color: #6774A8">排序条件(ORDER BY)</strong>
                    </th>
                    <td>
                        <select id="fieldsoption" style="width: 220px;">
                            <%=BuildDataFieldsList(modelTagModule.OrderBy)%>
                        </select>
                        <select id="direction">
                            <option value="ASC" <%=modelTagModule.Direction=="ASC"?"selected='selected'":"" %>>ASC-升序</option>
                            <option value="DESC" <%=modelTagModule.Direction=="DESC"?"selected='selected'":"" %>>
                                DESC-降序</option>
                        </select>
                        <span class="red">数据的排序方式</span>
                    </td>
                </tr>
                <tr>
                    <th class="th">
                        <strong style="color: #6774A8"></strong>
                    </th>
                    <td>
                        <input type="button" id="btnadd" name="btnadd" value="<%=btnStr %>模块代码" onclick='return GetCode("<%=KeRui.Common.PageRequest.GetString("act") %>","<%=KeRui.Common.PageRequest.GetString("id") %>");'
                            class="button" style="visibility:<%=btnVisible %>" />&nbsp;<input type="button" id="btnreturn" name="return" value="取消"
                                onclick='window.location.href="ModuleList.aspx"' class="button" />
                    </td>
                </tr>
            </table>
        </div>
        <div id="setp_2">
            <table>
                <tr>
                    <th class="th">
                        <strong style="color: #6774A8">模块代码</strong>
                    </th>
                    <td>
                        <textarea id="txtcode" style="width: 300px; height: 150px;"></textarea>
                        <br />
                        <input type="button" id="Button2" name="copyto" value="复制到剪切板" onclick='copyToClipboard($("#txtcode").val())'
                            class="button" />&nbsp;<input type="button" id="return" name="return" value="返回模块管理"
                                onclick='window.location.href="ModuleList.aspx"' class="button" /><br />
                        <span class="red">将此段代码放置在foreach标签的from处即可</span>
                    </td>
                </tr>
            </table>
        </div>
        
        <div id="setp_3">            
            <%=InfoView %>
        </div>
        
    </form>
</body>
</html>
